/*
 *  HeartBeatController.h
 *  project8
 *
 *  Created by Luca Gobbo on 21-06-10.
 *  Copyright 2010 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef _MONITORCONTROLLER_H
#define _MONITORBEATCONTROLLER_H


#include "pRTOS.h"
#include "Timer.h"
#include "TimerListener.h"
#include "Button.h"
#include "ButtonListener.h"
#include "Clock.h"
#include "DisplayMonitor.h" 
#include "HeartBeatController.h" 

class Button; // forward decleration

class MonitorController: public cTask, public ButtonListener, public TimerListener {	
	
public:         
                            
    MonitorController(Button* set,Button* mode,DisplayMonitor* dm,HeartBeatController * hbc);		
    void timeout(Timer* src);
    void init();
    void update();      
    void buttonUp(Button* b);
    void buttonDown(Button* b);    
    
private:
    enum Status {
    STB,
		RUN,
		AVG,
		HIGH,
		LOW
    };
	Status state;
	cEventFlagGroup buttonFlags;
	Button* theSetButton;
	Button* theModeButton;
	Clock clock;
	Timer timer;
	DisplayMonitor* theDisplayMonitor; 
	HeartBeatController* theHeartBeatController;
	
	enum Flags{
    btnFlagNo0,
    btnFlagNo1,
    btnFlagNo2,
    btnFlagNo3,
    timerFlagNo
  };
	
};


#endif
